package us.mooresr.geartrack.client.events;

import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import us.mooresr.geartrack.shared.model.Loan;
import com.google.gwt.event.shared.HasHandlers;

public class LoanChangedEvent extends
		GwtEvent<LoanChangedEvent.LoanChangedHandler> {

	public static Type<LoanChangedHandler> TYPE = new Type<LoanChangedHandler>();
	private Loan loan;

	public interface LoanChangedHandler extends EventHandler {
		void onLoanChanged(LoanChangedEvent event);
	}

	public LoanChangedEvent(Loan loan) {
		this.loan = loan;
	}

	public Loan getLoan() {
		return loan;
	}

	@Override
	protected void dispatch(LoanChangedHandler handler) {
		handler.onLoanChanged(this);
	}

	@Override
	public Type<LoanChangedHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<LoanChangedHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, Loan loan) {
		source.fireEvent(new LoanChangedEvent(loan));
	}
}
